<?php get_instance()->view('common/header');?>
<link rel="stylesheet" href="<?php echo $this->staticUrl?>css/jquery-weui.css">
<body>
<div class="saixuan threesai">
    <a href="<?php echo getUrl('user/coupon?status=1')?>" >未使用（<?php echo $not_use?>）</a>
    <a href="<?php echo getUrl('user/coupon?status=2')?>"  <?php if ($status == 2):?>class="actived"<?php endif;?> >已使用（<?php echo $use?>）</a>
    <a href="<?php echo getUrl('user/coupon?status=3')?>" <?php if ($status == 3):?>class="actived"<?php endif;?> >已过期（<?php echo $out_date?>）</a>
    <div class="after"></div>
</div>
<?php if (!empty($list)):?>
    <div class="waper">
        <?php foreach ($list as $k => $v):?>
            <div class="cashitem cashitemyi">
                <div class="heng cashitemcons">
                    <div class="left">
                        <div class="vCenter">
                            <div class="borimgbox imgbox"><img src="<?php echo $v['s_icon']['xs']?>" alt=""></div>
                            <p class="ml5 textEll" style="width: 6em;"><?php echo $v['s_name']?></p>
                        </div>
                    </div>
                    <div class="right">
                        <span class="fb dk tc">￥<b class="f18 fb lh10"><?php echo $v['money']?></b></span>
                        <p class="f08 tc"><?php echo $v['condition']?></p>
                    </div>
                </div>
                <div class="hengleft bor_tt pl20">
                    <p class="f08 cor9 p5_0"><?php if ($status == 2):?>已使用<?php else:?>已过期<?php endif;?></p>
                </div>
            </div>
        <?php endforeach;?>
    </div>
    <div class="weui-loadmore" style="display: none">
        <div class="load">
            <i class="weui-loading"></i>
            <span class="weui-loadmore__tips">正在加载</span>
        </div>
        <span class="weui-loadmore__tips f09 noC" style="display: none"><?php if ($status == 2):?>以上是近期已使用的代金券<?php else:?>以上是近期已过期的代金券 <?php endif;?></span>
    </div>
<?php else:?>
    <div class="statebox chuizhi jdjz" style="flex: 1;height: 100%;">
        <img class="stateimgda mb5" src="<?php echo $this->staticUrl?>img/png/pic68.png" alt="">
        <span class="f10 cor9 tc mb20">主人还没有可用的代金券哦！</span>
    </div>
<?php endif;?>
</body>
<script src="<?php echo $this->staticUrl?>js/base.js"></script>
<script src="<?php echo $this->staticUrl?>js/jquery-weui.js"></script>
<script type="text/javascript">
    $(function () {
        var page = 1;
        var loading = false;  //状态标记
        $(document.body).infinite().on("infinite", function() {
            if(loading) return;
            loading = true;
            $(".weui-loadmore").show();
            $(".load").show();
            $(".noC").hide();
            page++;
            $.get("<?php echo getUrl('user/couponAjax')?>",{page:page,status:<?php echo $status ?>},function (res) {
                $(".weui-loadmore").hide();
                $(".load").hide();
                if(res.data.length>0){
                    laytpl($("#listTmp").html()).render(res.data, function(html){
                        $(".waper").append(html);
                        loading = false;
                    });
                }else {
                    $(".weui-loadmore").show();
                    $(".noC").show();
                }
            },'json');
        });
    })
</script>
<script id="listTmp" type="text/html">
    {{# for(var i = 0 ; i < d.length ; i++){ }}
    <div class="cashitem cashitemyi">
        <div class="heng cashitemcons">
            <div class="left">
                <div class="vCenter">
                    <div class="borimgbox imgbox"><img src="{{ d[i].s_icon.xs }}" alt=""></div>
                    <p class="ml5 textEll" style="width: 6em;">{{ d[i].s_name }}</p>
                </div>
            </div>
            <div class="right">
                <span class="fb dk tc">￥<b class="f18 fb lh10">{{ d[i].money }}</b></span>
                <p class="f08 tc">{{ d[i].condition }}</p>
            </div>
        </div>
        <div class="hengleft bor_tt pl20">
            <p class="f08 cor9 p5_0"><?php if ($status == 2):?>已使用<?php else:?>已过期<?php endif;?></p>
        </div>
    </div>
    {{# } }}
</script>
</html>